package com.example.demo_job.mapper;


import com.example.demo_job.entity.Company;
import com.example.demo_job.entity.Seeker;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface CompanyMapper {

    @Select("SELECT * FROM Company WHERE cusername=#{cusername}")
    Company findByUsername(String cusername);

    @Select("SELECT * FROM Company WHERE cusername=#{cusername} AND cpassword=#{cpassword}")
    Company login(String cusername, String cpassword);

    @Insert("INSERT INTO Company(cusername, cpassword,cname,cyear,caddress,cemail,cphone,cinfo) VALUES(#{cusername},#{cpassword},#{cname},#{cyear},#{caddress},#{cemail},#{cphone},#{cinfo})")
    int register(String cusername, String cpassword, String cname, String cyear, String caddress, String cemail, String cphone, String cinfo);

    @Select("select cinfo from company where cusername=#{cusername}")
    String findInfo(String cusername);


    @Update("update  company set cname=#{cname},cyear=#{cyear},caddress=#{caddress},cemail=#{cemail},cphone=#{cphone} where cusername=#{cusername}")
    void UpdateCompany(String cusername, String cname, String cyear, String caddress, String cemail, String cphone);

    @Select("select * from seeker")
    List<Seeker> showseekers();
}
